package com.devilvan.betrice.europeacademy.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.devilvan.betrice.europeacademy.mapper.EuropeAcademyScholarshipMapper;
import com.devilvan.betrice.europeacademy.po.EuropeAcademyScholarshipPo;
import com.devilvan.betrice.europeacademy.repository.EuropeAcademyScholarshipRepository;
import com.devilvan.betrice.europeacademy.service.EuropeAcademyScholarshipService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Evad.Wu
 * @Description 欧洲学术成员 研究领域 业务逻辑类
 * @date 2022-09-06
 */
@Service
public class EuropeAcademyScholarshipServiceImpl extends ServiceImpl<EuropeAcademyScholarshipMapper, EuropeAcademyScholarshipPo> implements EuropeAcademyScholarshipService {
    @Resource(name = "europeAcademyScholarshipRepository")
    private EuropeAcademyScholarshipRepository repository;

    @Override
    public List<EuropeAcademyScholarshipPo> saveUpdateBatch(List<EuropeAcademyScholarshipPo> list) {
        return repository.saveAllAndFlush(list);
    }

    @Override
    public void deleteByMembershipId(Long membershipId) {
        LambdaUpdateWrapper<EuropeAcademyScholarshipPo> updateWrapper = new UpdateWrapper<EuropeAcademyScholarshipPo>().lambda();
        updateWrapper.eq(EuropeAcademyScholarshipPo::getMembershipId, membershipId);
        this.baseMapper.delete(updateWrapper);
    }
}
